<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insert title here</title>
<script type="text/javascript" src="/resource/js/jquery-3.2.1.js"></script>
<script type="text/javascript" src="/resource/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/resource/css/bootstrap.min.css">
<link rel="stylesheet" href="/resource/css/index.css">
<style type="text/css">
	img {
		max-width: 800px;
	}
</style>
</head>
<body>
	<div class="container">
		<div>
			<!-- 图片 -->
			<a href="/"> <img alt="" src="/resource/pic/logo-admin.jpg" height="50" width="100" ></a> 
			
			<div class="float-right align-items-center" >
			<br>
				<!-- 右侧的个人中心和退出按钮 -->
				<!-- 如果已经登录，则显示个人中心和退出 -->
					<c:if test="${user!=null }">
						你好，<b>${user.nickname }</b>
						<input class="btn btn-primary btn-sm" type="button" onclick="toCenter()" value="${user.role==0?'个人中心':'管理员中心' }">
						<input class="btn btn-primary btn-sm" type="button" onclick="logout()" value="退出">
					</c:if>
					
					
			</div><br>
		<hr>
		</div>
		
		<!-- 正文 -->
		<div class="row">
			<div class="col-md-2"></div>
			
			<div class="col-md-8">
				<h3><b>${article.title }</b></h3><br>
				<p>作者：${article.userName }  发布时间：${article.created }</p>
				<hr>
				${article.content }
			
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	//去个人中心
	function toCenter(){
		//获取角色role值
		var role = '${user.role}';
		
		//判断role值
		if(role == 0){
			//普通用户
			location="/my/";
		}else{
			//超级管理员
			location="/admin/";
		}
	}
	
	//退出登录
	function logout(){
		location="/user/logout";
	}

</script>
</html>